From: C. Scott Ananian Date: Thu, 17 Oct 2019 16:59:04 +0000 (-0400) Subject: Deprecate setting Parser::mTitle to null X-Git-Tag: 1.34.0-rc.1~22 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dmembres/Subpage_test/1/2/%5B%27/%40%20%27icone_supprimer_signature%27%20=%3E%20%27Delete%20this%20signature%27%2C%20%27icone_valider_signature%27%20=%3E%20%27Validate%20this%20signature%27%2C%20%27image_administrer_rubrique%27%20=%3E%20%27You%20can%20manage%20this%20section%27%2C-%27impossible_modifier_login_auteur%27%20=%3E%20%27Login%20cannot%20be%20changed.%27%2C-%27impossible_modifier_pass_auteur%27%20=%3E%20%27Password%20cannot%20be%20changed.%27%2C%20%27info_1_article%27%20=%3E%20%271%20article%27%2C-%27info_1_article_syndique%27%20=%3E%20%271%20syndicated%20article%27%2C%20%27info_1_auteur%27%20=%3E%20%271%20author%27%2C%20%27info_1_message%27%20=%3E%20%271%20message%27%2C%20%27info_1_mot_cle%27%20=%3E%20%271%20keyword%27%2C%20%27info_1_rubrique%27%20=%3E%20%271%20section%27%2C-%27info_1_site%27%20=%3E%20%271%20site%27%2C%20%27info_1_visiteur%27%20=%3E%20%271%20visitor%27%2C%20%27info_activer_cookie%27%20=%3E%20%27You%20can%20activate%20an%20%3Cb%3Eadministration%20cookie%3C/b%3E%2C%20which%20allows%20you%20%20to%20switch%20easily%20between%20the%20public%20site%20and%20the%20private%20area.%27%2C%40%40%20-249%2C16%20%20213%2C13%20%40%40%20Do%20not%20submit%20this%20import%20request.%3Cp%3EFor%20more%20information%2C%20please%20see%20%3Ca%20href=?a=commitdiff_plain;h=ba76dfdd050b83eb124ef2f12a6f22c467133fca;p=lhc%2Fweb%2Fwiklou.git Deprecate setting Parser::mTitle to null This never happens in core code; however extensions have slipped into a state of sin. Bug: T235392 Change-Id: Ia254949cd8b3bc162b11dcc911dcce40d91bf1b7 (cherry picked from commit dd9e6124b4a47b98cccdaa2971d587ecc6f0ab6e) --- diff --git a/RELEASE-NOTES-1.34 b/RELEASE-NOTES-1.34 index ed2cf9c2e3..d34d14bb2b 100644 --- a/RELEASE-NOTES-1.34 +++ b/RELEASE-NOTES-1.34 @@ -619,6 +619,9 @@ because of Phabricator reports. fetchLanguageName, getFileName, getMessagesFileName, getJsonMessagesFileName. Use the new LanguageNameUtils class instead. (Note that fetchLanguageName(s) are called getLanguageName(s) in the new class.) +* Using the Parser without initializing its $mTitle property to non-null has + been deprecated. In a future release Parser::getTitle() will throw a + TypeError if $mTitle is uninitialized. === Other changes in 1.34 === * Added option to specify "Various authors" as author in extension credits using diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index ae77c4ef03..3aa2c69ffa 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -228,7 +228,11 @@ class Parser { public $mOptions; /** - * @var Title|null Beware - this is not always set + * Since 1.34, leaving `mTitle` uninitialized or setting `mTitle` to + * `null` is deprecated. + * + * @internal + * @var Title|null */ public $mTitle; # Title context, used for self-link rendering and similar things public $mOutputType; # Output type, one of the OT_xxx constants @@ -924,9 +928,14 @@ class Parser { /** * Accessor for the Title object * + * Since 1.34, leaving `mTitle` uninitialized as `null` is deprecated. + * * @return Title|null */ public function getTitle() : ?Title { + if ( $this->mTitle === null ) { + wfDeprecated( 'Parser title should never be null', '1.34' ); + } return $this->mTitle; }